package com.woniuxy.stage3demo.mapper.gy;

import com.woniuxy.stage3demo.bean.gy.OverdueBean;
import com.woniuxy.stage3demo.bean.gy.ResultMesDemo;
import com.woniuxy.stage3demo.bean.gy.UserDemo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OverdueMapper {
    //7表联查,查询逾期人员信息
    public List<OverdueBean> findAll(@Param("u") UserDemo userDemo);


    //7表联查,查询可减免信息
    public List<OverdueBean> findAllReduce(@Param("u") UserDemo userDemo);

    //查询逾期人数
    @ResultType(int.class)
    @Select("select count(id) from overdue " +
            "where date_format(real_repayment_time,'%Y%m')=date_format(curdate(),'%Y%m')")
    public int findCountMonth();

    //查询每年的逾期总数
    @Select("select count(id) from overdue " +
            "where YEAR(real_repayment_time)=YEAR(NOW())")
    public int findCountYear();


    //查询每个月的逾期金额和利息
    @ResultType(ResultMesDemo.class)
    @Select("select o.should_repay_principal realPrincipal,o.should_repay_interest realInterest from overdue o " +
            "where date_format(real_repayment_time,'%Y%m')=date_format(curdate(),'%Y%m')")
    public List<ResultMesDemo> findMonthMoney();


    //查询每年的逾期金额和利息
    @ResultType(ResultMesDemo.class)
    @Select("select o.should_repay_principal realPrincipal,o.should_repay_interest realInterest from overdue o " +
            "where YEAR(real_repayment_time)=YEAR(NOW())")
    public List<ResultMesDemo> findYearMoney();


    //罚息减免
    public int updateLateCharge(@Param("id") int id,@Param("l") int lateCharge);

    //查询罚息
    @ResultType(int.class)
    @Select("select late_charge from overdue where id=#{id}")
    public int findLateCharge(@Param("id")int id);
}
